package com.tunnel.home.dao;

import java.util.Date;

import org.axe.annotation.persistence.Dao;
import org.axe.annotation.persistence.Sql;
import org.axe.interface_.persistence.BaseRepository;

import com.tunnel.home.entity.User;

@Dao
public interface UserDao extends BaseRepository{
	
	@Sql("select * from User where email=?1 limit 1")
	public User getUser(String email);
	
	@Sql("update User set password=?2,emailStatus=1 where id=?1")
	public int resetPassword(long userId,String password);
	
	@Sql("select * from User where id=?1")
	public User getUser(long id);
	
	@Sql("select * from User where token=?1")
	public User getUserByToken(String token);
	
	@Sql("update User set emailStatus=1 where id=?1")
	public int activeEmail(long id);
	
	@Sql("update User set token=?2 where id=?1")
	public int setToken(long id,String token);

	@Sql("update User set status=0 where expireTime<now()")
	public int refreshUserStatus();
	
	@Sql("update User set status=1,expireTime=?2 where id=?1")
	public int addExpireDays(long id,Date expireTime);
}
